package com.world.common.jwt;

import cn.hutool.crypto.KeyUtil;
import cn.hutool.jwt.signers.AlgorithmUtil;
import cn.hutool.jwt.signers.JWTSigner;
import cn.hutool.jwt.signers.JWTSignerUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.security.KeyPair;

/**
 * hutool jwt工具类
 *
 * @author WangYX
 * @version 1.0.0
 * @date 2023/06/02 11:43
 */
@Configuration
public class JwtConfiguration {

    @Bean
    public JWTSigner signer() {
        String id = "rs256";
        KeyPair keyPair = KeyUtil.generateKeyPair(AlgorithmUtil.getAlgorithm(id));
        return JWTSignerUtil.createSigner(id, keyPair);
    }
}
